<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<style>
    html,
    body,
    #box {
        height: 100%;
        width: 100%;
        overflow: hidden;
    }


    body {
        display: flex;
        flex-direction: column;
    }

    #content {
        /* display: flex;
        width: 100%;
        height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        flex-wrap: wrap;
        flex-direction: column; */
        columns: 200px auto;
    }

    .item {
        width: 200px;
        break-inside: avoid; 
        margin-bottom: 10px;
        margin-right: 10px;
    }

    #box{
        overflow: auto;
    }
</style>

<body>
    <div id="box">
        <div id='content'></div>
    </div>
</body>

<script>
    const box = document.querySelector('#content');
    const colorArray = ['grey', 'blue', 'red'];

    Array.from({ length: 60 }).forEach(createItem);

    const resizeObserver = new ResizeObserver(entries => {
      for (const entry of entries) {
      }
    });

    resizeObserver.observe(box);

    function createItem() {
      const item = document.createElement('div');
      item.classList.add('item');
      item.style.height = `${Math.ceil(Math.random() * 60) + 200}px`;
      item.style.background =
        colorArray[Math.floor(Math.random() * colorArray.length)];

      box.append(item);
    }
</script>

</html>